﻿@using DMS.BO.Web.Ajax
@model DMS.BO.Models.ProductFilter

<div class="box">
    <div class="box-content">
        @using (Ajax.BeginForm("Edit", "Product", new BOAjaxOptions{ OnSuccess = "OnSuccess_createForm" }, new { id = "createForm" }))
        {
            <div class="control-group">
                <div class="span5">
                    <label for="textfield" class="control-label">ID (*)</label>
                    <div class="controls">
                        @Html.TextBoxFor(x=>x.ID,new {@id="ID",@disabled="disabled"})
                        <input type="hidden" name="ID" value="@Model.ID"/>
                    </div>
                </div>
                <div class="span5">
                    <label for="textfield" class="control-label">Name (*)</label>
                    <div class="controls">
                        @Html.TextBoxFor(x=>x.Name,new {@id="Name"})
                    </div>
                </div>
            </div>
            <div class="form-actions">
                <button type="submit" class="btn btn-primary">Lưu</button>
                <button type="button" id="btnCancel" class="btn btn-primary">Thoát</button>
            </div>
        }
    </div>
</div>

<script type="text/javascript">
 $(document).ready(function () {
        jQuery.validator.unobtrusive.parse('#createForm');
    });
    
    function OnSuccess_createForm(response) {
        alert(response.Message);
        if (response.Code==0) {
            $("#divDialog").dialog('close');
            $('#frmProduct').submit();
        }
    }
    $('#createForm #btnCancel').click(function () {
        $('#divDialog').dialog('close');
    });
    </script>